package com.hy.mydesktop.client.component.factory;

import com.extjs.gxt.ui.client.widget.Layout;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.hy.mydesktop.client.component.meta.AccordionPanelModelEnum;
import com.hy.mydesktop.client.component.meta.TabPanelModelEnum;
import com.hy.mydesktop.client.component.type.ComponentTypeEnum;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;

/**
 * 
 * <ul>
 * <li>开发作者：冬超</li>
 * <li>设计日期：2010-8-29；时间：下午04:12:15</li>
 * <li>类型名称：TabPanelFactory</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class TabPanelFactory {

	public static TabPanel createTabPanel(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {

		return configureTabPanel(gxtComponentMetaNodeModel);

	}

	/**
	 * 
	 * 
	 * @param gxtComponentMetaNodeModel
	 * @return
	 */
	private static TabPanel configureTabPanel(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {

		TabPanel tabPanel = createDefaultTabPanel();
		tabPanel = AbstractComponetFactory.configureAbstractComponet(tabPanel, gxtComponentMetaNodeModel);

		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.WIDHT.name()
				.toLowerCase()) != null) {
			String width = (String) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.WIDHT.name().toLowerCase());
			tabPanel.setWidth(width);

		} 
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.ANIMSCROLL
				.name().toLowerCase()) != null) {
			Boolean animScroll = (Boolean) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.ANIMSCROLL.name().toLowerCase());
			tabPanel.setAnimScroll((boolean) animScroll);

		}
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.CLOSECONTEXTMENU
				.name().toLowerCase()) != null) {
			Boolean closeContextMenu = (Boolean) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.CLOSECONTEXTMENU.name()
							.toLowerCase());
			tabPanel.setCloseContextMenu((boolean) closeContextMenu);

		} 
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.HIGHT.name()
				.toLowerCase()) != null) {
			Integer height = (Integer) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.HIGHT.name().toLowerCase());
			tabPanel.setHeight((int) height);

		} 
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.MINTABWIDTH
				.name().toLowerCase()) != null) {
			Integer minTabWidth = (Integer) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.MINTABWIDTH.name().toLowerCase());
			tabPanel.setMinTabWidth((int) minTabWidth);

		} 
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.RESIZE.name()
				.toLowerCase()) != null) {
			Boolean resize = (Boolean) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.RESIZE.name().toLowerCase());
			tabPanel.setResizeTabs((boolean) resize);

		} 
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.TABSCROll.name()
				.toLowerCase()) != null) {
			Boolean tabScroll = (Boolean) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.TABSCROll.name().toLowerCase());
			tabPanel.setTabScroll(tabScroll);

		} 
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.TITLE.name()
				.toLowerCase()) != null) {
			String title = (String) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.TITLE.name().toLowerCase());
			tabPanel.setTitle(title);

		} 
		if (gxtComponentMetaNodeModel.get(TabPanelModelEnum.PIAN.name()
				.toLowerCase()) != null) {
			Boolean plain = (Boolean) gxtComponentMetaNodeModel
					.get(TabPanelModelEnum.PIAN.name().toLowerCase());
			tabPanel.setPlain(plain);

		
		}

		return tabPanel;
	}

	private static TabPanel createDefaultTabPanel() {

		TabPanel tabPanel = new TabPanel();
		return tabPanel;
	}
}
